package com.canyou.redmine.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.canyou.redmine.R;

import java.util.List;

/**
 * Created by Administrator on 2018-01-03.
 */

public class FragmentAdapter extends FragmentPagerAdapter {
    private Context context;
    private List<Fragment> fragments;
    private int[] mTitles = {
            R.string.projects, R.string.tasks,
            R.string.issues, R.string.settings
    };

    public FragmentAdapter(Context context, FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.context = context;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return context.getText(mTitles[position]);
    }
}
